var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    loading:true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.getData();
  },
  getData:function(res){
    var that = this;
    app.getLoginSession(function (session) {
      wx.request({
        url: app.api + '/index/category',
        data:{
          t_session:session
        },
        success:function (res) {
          var res = res.data;
          console.log(res);
          if (res.done) {
            var data = res.retval
            that.setData({
              list: data.list,
              loading: false
            })
          } else {
            that.setData({
              loading: true,
              errorTips: '接口请求错误'
            })
          }
        },
        fail:function (res) {
          that.setData({
            loading: true,
            errorTips: '接口请求错误'
          })
        }
      })
  })
  },
  onShareAppMessage: function () {
  
  }
})